home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-05 / driverss.zip / NI5210.ASM < prev    next >
Assembly Source File  |  1991-01-26  |  5KB  |  204 lines

  1. version    equ    2
  2.  
  3.     include    defs.asm
  4.  
  5. ;Ported from Tim Krauskopf's micnet.asm, an assembly language
  6. ;driver for the MICOM-Interlan NI5210, by Russell Nelson.  Any bugs
  7. ;are due to Russell Nelson.
  8. ;Updated to version 1.08 Feb. 17, 1989 by Russell Nelson.
  9. ;Updated to support 1500 byte MTU April 27, 1989 By Brad Clements.
  10.  
  11. ;  Copyright, 1988, 1989, Russell Nelson
  12.  
  13. ;   This program is free software; you can redistribute it and/or modify
  14. ;   it under the terms of the GNU General Public License as published by
  15. ;   the Free Software Foundation, version 1.
  16. ;
  17. ;   This program is distributed in the hope that it will be useful,
  18. ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. ;   GNU General Public License for more details.
  21. ;
  22. ;   You should have received a copy of the GNU General Public License
  23. ;   along with this program; if not, write to the Free Software
  24. ;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  25.  
  26. code    segment    word public
  27.     assume    cs:code, ds:code
  28.  
  29. ;
  30. ;  Equates for controlling the MICOM board
  31. ;
  32. ;  I/O addresses, writing anything in AL trips these gates
  33. ;
  34. ;  First six addresses are the EPROM board Ether address (read)
  35. ;
  36. IORESET    EQU    0            ; reset the board
  37. IOCA    EQU    1            ; execute command which is in SCB
  38. IODIS    EQU    2            ; disable network connect
  39. IOENA    EQU    3            ; enable network
  40. IOINTON    EQU    4            ; enable interrupts
  41. IOINTOF    EQU    5            ; disable interrupts, '586 thinks it still ints
  42.  
  43. ;
  44. ;  Data segment
  45. ;
  46.  
  47.     public    int_no
  48. int_no        db    2,0,0,0        ; interrupt number. 
  49. io_addr        dw    0360h,0        ; I/O address for card (jumpers)
  50. base_addr    dw      0d000h,0    ; base segment for board (jumper set)
  51.  
  52.     public    driver_class, driver_type, driver_name, driver_function, parameter_list
  53. driver_class    db    BLUEBOOK, IEEE8023, 0        ;from the packet spec
  54. driver_type    db    11        ;from the packet spec
  55. driver_name    db    "NI5210",0    ;name of the driver.
  56. driver_function    db    2
  57. parameter_list    label    byte
  58.     db    1    ;major rev of packet driver
  59.     db    9    ;minor rev of packet driver
  60.     db    14    ;length of parameter list
  61.     db    EADDR_LEN    ;length of MAC-layer address
  62.     dw    GIANT    ;MTU, including MAC headers
  63.     dw    MAX_MULTICAST * EADDR_LEN    ;buffer size of multicast addrs
  64.     dw    0    ;(# of back-to-back MTU rcvs) - 1
  65.     dw    0    ;(# of successive xmits) - 1
  66. int_num    dw    0    ;Interrupt # to hook for post-EOI
  67.             ;processing, 0 == none,
  68.  
  69. enable_network:
  70. ;  connect to network
  71.     loadport
  72.     setport    IOENA            ; enable network
  73.     out    dx,al            ; any al value
  74.     ret
  75.  
  76.  
  77. reset_586:
  78. ;  Reset the chip
  79.     loadport
  80.     setport    IORESET
  81.     out    dx,al
  82.     ret
  83.  
  84.  
  85.     public    get_address
  86. get_address:
  87. ;get the address of the interface.
  88. ;enter with es:di -> place to get the address, cx = size of address buffer.
  89. ;exit with nc, cx = actual size of address, or cy if buffer not big enough.
  90.     assume    ds:code
  91.     cmp    cx,EADDR_LEN        ;make sure that we have enough room.
  92.     jb    get_address_2
  93.     mov    cx,EADDR_LEN
  94.     mov    dx,io_addr        ; Get our IO base address.
  95.     cld
  96. get_address_1:
  97.     in    al,dx            ; get a byte of the eprom address
  98.     stosb                ; put it away
  99.     inc    dx            ; next register
  100.     loop    get_address_1        ; go back for rest
  101.     mov    cx,EADDR_LEN
  102.     clc
  103.     ret
  104. get_address_2:
  105.     stc
  106.     ret
  107.  
  108.  
  109. doca:
  110. ;we may be called from places in which ds is unknown.
  111.     assume    ds:nothing
  112.     loadport
  113.     setport    IOCA
  114.     out    dx,al            ; send it
  115.     ret
  116.     assume    ds:code
  117. ;yet, we really should assume ds==code for the rest of this stuff.
  118.  
  119. ;
  120. ; Here we include the code that is common between 82586 implementations.
  121. ; Everything above this is resident.
  122.     include    82586.asm
  123. ; Everything below this is discarded upon installation.
  124.  
  125.     public    usage_msg
  126. usage_msg    db    "usage: ni5210 [-n] [-d] [-w] <packet_int_no> <int_no> <io_addr> <base_addr>",CR,LF,'$'
  127.  
  128.     public    copyright_msg
  129. copyright_msg    db    "Packet driver for the MICOM-Interlan NI5210, version ",'0'+majver,".",'0'+version,".",'0'+i82586_version,CR,LF
  130.         db    "Portions Copyright 1988 The Board of Trustees of the University of Illinois",CR,LF,'$'
  131.  
  132. check_board:
  133.     mov    SCP,1
  134.     mov    dx,io_addr    ; i/o address
  135.     add    dx,EADDR_LEN    ; look past the ethernet address.
  136.     in    al,dx
  137.     mov    bl,al        ; assemble pattern to check
  138.     inc    dx
  139.     in    al,dx
  140.     mov    bh,al
  141.     cmp    bx,05500h        ; pattern known to be there in ROM
  142.     jz    have_5210_io
  143.     pop    dx            ;drop our return address
  144.     mov    dx,offset no_5210_io_msg
  145.     jmp    error
  146. have_5210_io:
  147.  
  148.     mov    ax,base_addr
  149.     mov    cx,2000h        ;test only what we are going to use.
  150.     call    memory_test
  151.     jz    have_5210_mem
  152.     pop    dx            ;drop our return address
  153.     mov    dx,offset no_5210_mem_msg
  154.     jmp    error
  155. have_5210_mem:
  156.     ret
  157.  
  158.  
  159. no_5210_io_msg    db    "No 5210 found at that I/O address.",CR,LF,'$'
  160. no_5210_mem_msg    db    "No 5210 found at that memory address.",CR,LF,'$'
  161.  
  162.     public    parse_args
  163. parse_args:
  164.     mov    di,offset int_no
  165.     call    get_number
  166.     mov    di,offset io_addr
  167.     call    get_number
  168.     mov    di,offset base_addr
  169.     call    get_number
  170.     clc
  171.     ret
  172.  
  173.  
  174. int_no_name    db    "Interrupt number ",'$'
  175. io_addr_name    db    "I/O port ",'$'
  176. base_addr_name    db    "Memory address ",'$'
  177.  
  178.  
  179.     public    print_parameters
  180. print_parameters:
  181.     mov    di,offset int_no
  182.     mov    dx,offset int_no_name
  183.     call    print_number
  184.     mov    di,offset io_addr
  185.     mov    dx,offset io_addr_name
  186.     call    print_number
  187.     mov    ax,memory_begin
  188.     mov    cl,4
  189.     shr    ax,cl
  190.     add    base_addr,ax
  191.     push    ax
  192.     mov    di,offset base_addr
  193.     mov    dx,offset base_addr_name
  194.     call    print_number
  195.     pop    ax
  196.     sub    base_addr,ax
  197.     ret
  198.  
  199.     include    memtest.asm
  200.  
  201. code    ends
  202.  
  203.     end
  204.